}
});
+export const Sound = GObject.registerClass(
+class Sound extends GObject.Object {
+ constructor(file, themedName) {
+ super();
+
+ this._soundFile = file;
+ this._soundName = themedName;
+ }
+
+ play() {
+ const player = global.display.get_sound_player();
+
+ if (this._soundName)
+ player.play_from_theme(this._soundName, _('Notification sound'), null);
+ else if (this._soundFile)
+ player.play_from_file(this._soundFile, _('Notification sound'), null);
+ }
+});
+
// Notification:
// @source: the notification's Source
// @title: the title
this.forFeedback = false;
this.bannerBodyText = null;
this.bannerBodyMarkup = false;
- this._soundName = null;
- this._soundFile = null;
+ this.sound = null;
this._soundPlayed = false;
this.actions = [];
this.setResident(false);
bannerMarkup: false,
clear: false,
datetime: null,
- soundName: null,
- soundFile: null,
+ sound: null,
});
this.title = title;
if (params.clear)
this.actions = [];
- if (this._soundName !== params.soundName ||
- this._soundFile !== params.soundFile) {
- this._soundName = params.soundName;
- this._soundFile = params.soundFile;
+ if (this.sound !== params.sound) {
+ this.sound = params.sound;
this._soundPlayed = false;
}
return;
}
- let player = global.display.get_sound_player();
- if (this._soundName)
- player.play_from_theme(this._soundName, this.title, null);
- else if (this._soundFile)
- player.play_from_file(this._soundFile, this.title, null);
+ this.sound?.play(this.title);
}
// Allow customizing the banner UI: